package com.ruoyi.system.api.permission;

import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.system.api.permission.dto.DeptDataPermissionRespDTO;
import com.ruoyi.system.service.IPermissionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Set;

@Service
public class PermissionApiImpl implements PermissionApi {

    @Resource
    private IPermissionService permissionService;

    @Override
    public R<Set<Long>> getUserRoleIdListByRoleIds(Collection<Long> roleIds) {
        return R.ok(permissionService.getUserRoleIdListByRoleId(roleIds));
    }

    @Override
    public R<Boolean> hasAnyPermissions(Long userId, String... permissions) {
        return R.ok(permissionService.hasAnyPermissions(userId, permissions));
    }

    @Override
    public R<Boolean> hasAnyRoles(Long userId, String... roles) {
        return R.ok(permissionService.hasAnyRoles(userId, roles));
    }

    @Override
    public R<DeptDataPermissionRespDTO> getDeptDataPermission(Long userId) {
        return R.ok(permissionService.getDeptDataPermission(userId));
    }

}
